package main

import "fmt"

type Person101 struct {
	Name string
	Sex  byte
	Age  int
}
type Student101 struct {
	Person101 // 结构体匿名字段
	addr      string
}

func (person *Person101) printInfo() {
	person.Name = "aaa"
	fmt.Printf("&p = %p\n", person)
	fmt.Printf("name=%s, sex=%d, age=%d\n", person.Name, person.Sex, person.Age)
}

func (person Person101) printInfo2() {
	fmt.Printf("&p = %p\n", &person)

	person.Name = "zzz"
	fmt.Printf("name=%s, sex=%d, age=%d\n", person.Name, person.Sex, person.Age)
}

func main() {
	s := Student101{
		Person101: Person101{
			Name: "xdc",
			Sex:  1,
			Age:  2,
		},
		addr: "beijing",
	}
	fmt.Printf("&stu = %p\n", &s)

	s.Person101.Name = "lll"
	s.printInfo()
	fmt.Println("printInfo: ", s)

	s.printInfo2()

	fmt.Println("printInfo2: ", s)
}
